package day8;

import java.util.Scanner;

public interface juice {
    void genarate();
}

class Apple implements juice {
    public void genarate() {
        System.out.println("生产苹果汁");
    }
}

class Watermelon implements juice {
    public void genarate() {
        System.out.println("生产西瓜汁");
    }
}

class TestFruit{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你需要的果汁");
        int n = sc.nextInt();
        //多态  父类引用 = 子类对象
        juice f=null;
        switch(n){
            case 1:f=new Apple();break;
            case 2:f=new Watermelon();break;
        }
        f.genarate();
    }
}